Replication Materials  
-----------------------------

Authors:  
Wei Zhong  
Maggie Mengqing Zhang  

Manuscript Title:  
Subdued but Unbroken: The Cohesion of Far-Right Extremist Followers After Twitter’s Deplatforming  

Forthcoming in:  
Perspectives on Politics  

-----------------------------
Overview  
-----------------------------

This repository contains two Python scripts—code_01.py and code_02.py—used to conduct 
Interrupted Time Series (ITS) analysis on the following measures:

- Task Commitment: Frequency and proportion of hashtags, URLs, and ideological narratives  
- Social Commitment: Density of co-shared hashtags, co-shared URLs, and retweet networks  
- Sense of Belonging: Frequency and proportion of expressions indicating belonging  

The analysis examines changes surrounding a key platform policy intervention.

- code_01.py models trends in hashtags, URLs, ideological narratives, and expressions of belonging.  
- code_02.py analyzes retweet network density and co-sharing network density (hashtags and URLs).

-----------------------------
ITS Pipeline Components  
-----------------------------

Each script automates a full ITS pipeline, including:

- Data loading and normalization  
- ITS-specific data formatting  
- OLS and ARIMA model fitting  
- Counterfactual outcome simulation  
- Visualization of trends before and after the intervention  
- Effect size estimation with confidence intervals and p-values

-----------------------------
Script Contents and Output Mapping  
-----------------------------

code_01.py – Performs ITS analysis for:  
- Hashtag frequency and proportion -> Figure 1  
- URL sharing frequency and proportion -> Figure 2  
- Ideological narrative frequency and proportion -> Figure 3  
- Sense of belonging indicators -> Figure 6  

code_02.py – Performs ITS analysis for social engagement measures:  
- Retweet network density (overall, among insiders, and broader audience) -> Figure 4  
- Co-sharing hashtag network density -> Figure 5  
- Co-sharing URL network density -> Figure 5  

Note: Due to the stochastic nature of ARIMA simulations in counterfactual modeling, effect 
sizes may vary slightly across runs. However, direction and statistical significance remain stable.

-----------------------------
Software Used  
-----------------------------

- Python 3.10+  
- Jupyter Notebook (optional, for testing and exploratory analysis)

-----------------------------
Required Packages  
-----------------------------

These scripts rely on the following Python libraries:

- os, sys, glob, re, datetime, collections, pickle, warnings, ujson  
- pandas, numpy, scipy.stats, matplotlib.pyplot, matplotlib.dates  
- statsmodels.api, statsmodels.formula.api, statsmodels.tsa.arima.model  
- pmdarima.arima, tld, urlexpander, tqdm

-----------------------------
Data Folder Contents  
-----------------------------

The data/ directory contains all input files needed to replicate the ITS analyses:

- summary_df_domains.csv – Weekly frequency and proportion of domain sharing (task commitment)  
- summary_df_hashtags.csv – Weekly frequency and proportion of hashtag usage (task commitment)  
- summary_df_hate.csv – Weekly frequency and proportion of ideological narratives (task commitment)  
- summary_df_identity.csv – Weekly frequency and proportion of identity-related expressions (sense of belonging)  
- week_breaks_index.pkl – Mapping of week indices to calendar start dates (ITS timeline alignment)  
- weekly_density_codomain.csv – Co-shared domain network density (social commitment)  
- weekly_density_cohashtag.csv – Co-shared hashtag network density (social commitment)  
- weekly_density_retweet_all.csv – Retweet network density among all Proud Boys–connected users (social commitment)  
- weekly_density_retweet_non_pb.csv – Retweet network density between Proud Boys followers and non–Proud Boys followers (social commitment)  
- weekly_density_retweet_pb.csv – Retweet network density among Proud Boys followers only (social commitment)  



